package com.amita.ez.web;

import com.amita.ez.entity.SysUser;
import com.amita.ez.service.IUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@RestController
public class BaseCtrl {

    @Autowired
    HttpServletRequest request;

    @Autowired
    IUserInfoService userInfoService;

    public SysUser getLoginUser(){
        String token = request.getHeader("Authorization");
        Assert.notNull(token, "no token found");
        return userInfoService.getByToken(token);
    }
}
